﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BlogSystem.EntityFrameworkCore.Migrations
{
    public partial class init1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Category",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    category_name = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "文章类型名称")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Category", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "News",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    author = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "文章作者"),
                    title = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "文章标题"),
                    content = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "文章内容"),
                    key = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "文章摘要"),
                    category_id = table.Column<int>(type: "int", nullable: false, comment: "文章类型Id"),
                    category_name = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "文章类型名称"),
                    hit = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "回复数"),
                    reply_count = table.Column<int>(type: "int", nullable: false, comment: "文章回复数"),
                    publish_time = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "发布时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_News", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Reply",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    user_id = table.Column<int>(type: "int", nullable: false, comment: "用户ID"),
                    nick_name = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "昵称"),
                    reply_title = table.Column<int>(type: "int", nullable: false, comment: "评论标题"),
                    reply_content = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "评论内容"),
                    news_id = table.Column<int>(type: "int", nullable: false, comment: "文章ID"),
                    reply_date = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "评论时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Reply", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "User",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    user_name = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "用户名"),
                    password = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "密码"),
                    sex = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "性别"),
                    birthday = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "生日"),
                    email = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "邮箱"),
                    qq = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "QQ"),
                    create_time = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_User", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Category");

            migrationBuilder.DropTable(
                name: "News");

            migrationBuilder.DropTable(
                name: "Reply");

            migrationBuilder.DropTable(
                name: "User");
        }
    }
}
